<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <counter :count="count"></counter>
        <button @click="add">+</button>
    </div>
    <script src="vue.js"></script>
    <script>
        var vm = new Vue({
            el:'#app',
            data:{count:0},//父组件中定义要传递的数据
            methods:{add(){this.count++}},
            components:{
                counter:{
                    //通过props选项定义想要接收的属性
                    //Property or method "count" is not defined on the instance but referenced during render.
                    props:['count'],
                    data(){
                        return {
                            number:this.count
                        }
                    },
                    methods:{add(){this.number++}},
                    template:'<div @click="add">count:{{count}}number:{{number}}</div>'
                }
            }
        });
    </script>
</body>
</html>